<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../node_modules/react/umd/react.development.js"></script>
    <script src="../node_modules/react-dom/umd/react-dom.development.js"></script>
    <script src="../node_modules/babel-standalone/babel.js"></script>
</head>
<body>
    <div id="app"></div>
    <script type="text/babel">
    
        class Parent extends React.Component{

            constructor(props) {
                super(props);
            }

            render() {
                // 假装通过 ajax 得到了数据
                let users = [
                    {id: 's01', name: '张三', age: 21},
                    {id: 's02', name: '李四', age: 22},
                    {id: 's03', name: '王五', age: 23}
                ];

                return (
                    <ul>
                        {users.map((item, index) => (
                            <Child key={item.id} name={item.name} age={item.age} />
                        ))}
                    </ul>
                );
            }
            
        }

        class Child extends React.Component {
            constructor(props) {
                super(props);
            }

            render() {
                return (
                    <li>
                        name: {this.props.name} age: {this.props.age}
                    </li>
                );
            }
        }

        let oDiv = document.getElementById('app');

        ReactDOM.render(
            <Parent />,
            oDiv
        );
    </script>
</body>
</html>